class Costume {
    constructor(name = "Costume") {
        this.name = name;
        this.canvas = null;
    }

    get width() {
        return this.canvas.width;
    }

    get height() {
        return this.canvas.height;
    }

    load(src) {
        return new Promise((resolve, reject) => {
            var image = new Image();
            var self = this;

            image.onload = function() {
                self.canvas = document.createElement("canvas");
                self.canvas.width = image.width;
                self.canvas.height = image.height;
                self.canvas.getContext("2d").drawImage(image, 0, 0);
                resolve(self);
            }

            image.src = src;
        });
    }
}

export { Costume }